import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
// import Hi from '@/components/hi'
import H1 from '@/components/hi.1'
// import H2 from '@/components/hi.2'
import left from '@/components/left'
import right from '@/components/right'
import Parms from '@/components/Parms'
import ErrorPage from '@/components/Error'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      components: {
        default: HelloWorld,
        left: left,
        right: right
      }
    },
    {
      path: '/jspang',
      name: 'HelloWorld1',
      components: {
        default: HelloWorld,
        // 调换位置
        left: right,
        right: left
      }
    }, {
      path: '/params/:newsId(\\d+)/:newsTitle',
      component: Parms,
      beforeEnter: (to, from, next) => {
        console.log(to)
        console.log(from)
        // 可以往下跳转了
        next(true) // next(false)
      }
    }, {
      path: '/goHome',
      redirect: '/'
    }, {
      path: '/goParams/:newsId(\\d+)/:newsTitle',
      redirect: '/params/:newsId(\\d+)/:newsTitle'
    }, {
      path: '/h1',
      component: H1,
      alias: '/ccq'
    }, {
      path: '*',
      component: ErrorPage
    }
  ]
})
